<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<ui:composition>

<!-- TODO ajustar -->
	<h:panelGrid id="btnPadraoForm" columns="5">
		<c:if test="#{pManagedBean.tipoOperacao != 'DETALHANDO'}">

			<c:choose>
				<c:when test="#{pListaEFormularioNaMesmaPagina}">
					<!-- Ordem dos botões SalvarESair e SalvarEDuplicar -->
					<c:choose>
						<c:when
							test="#{pManagedBean.isInverterOrdemBotoesSalvarESair_SalvarEDuplicar}">
							<p:commandButton ajax="false" id="btnSalvarEDuplicar"
								actionListener="#{pManagedBean.doSalvarEDuplicar}"
								value="#{pManagedBean.labelSalvarEDuplicar}"
								update="panelFormularioEdicao,panelFiltroPesquisa,panelListagem,exportador#{pManagedBean.updateExtraBtnSalvarEDuplicar}"
								rendered="#{pManagedBean.isExibirBtnSalvarEDuplicar}" />
							<p:commandButton id="btnSalvarESair" ajax="false"
								actionListener="#{pManagedBean.doSalvarESair}"
								value="#{pManagedBean.labelSalvarSair}"
								update="panelFormularioEdicao,panelFiltroPesquisa,panelListagem,exportador#{pManagedBean.updateExtraBtnSalvarESair}"
								rendered="#{pManagedBean.isExibirBtnSalvarESair}" />
						</c:when>
						<c:otherwise>
							<p:commandButton id="btnSalvarESair" ajax="false"
								actionListener="#{pManagedBean.doSalvarESair}"
								value="#{pManagedBean.labelSalvarSair}"
								update="panelFormularioEdicao,panelFiltroPesquisa,panelListagem,exportador#{pManagedBean.updateExtraBtnSalvarESair}"
								rendered="#{pManagedBean.isExibirBtnSalvarESair}" />

							<p:commandButton ajax="false" id="btnSalvarEDuplicar"
								actionListener="#{pManagedBean.doSalvarEDuplicar}"
								value="#{pManagedBean.labelSalvarEDuplicar}"
								update="panelFormularioEdicao,panelFiltroPesquisa,panelListagem,exportador#{pManagedBean.updateExtraBtnSalvarEDuplicar}"
								rendered="#{pManagedBean.isExibirBtnSalvarEDuplicar}" />

						</c:otherwise>

					</c:choose>
					<ui:insert name="demaisBotoesFormulario" />

					<p:commandButton ajax="false" id="btnSalvar"
						actionListener="#{pManagedBean.doSalvar}"
						value="#{pManagedBean.labelSalvar}"
						update="panelFormularioEdicao,panelFiltroPesquisa,panelListagem,exportador#{pManagedBean.updateExtraBtnSalvar}"
						rendered="#{pManagedBean.isExibirBtnSalvar}" />

					<ui:insert name="demaisBotoesFormulario" />

					<p:commandButton ajax="false" id="btnCancelar"
						actionListener="#{pManagedBean.doCancelar}"
						update="panelFormularioEdicao,panelFiltroPesquisa,panelListagem,exportador"
						value="#{pManagedBean.labelCancelar}" immediate="true"
						rendered="#{pManagedBean.isExibirBtnCancelar}" />

				</c:when>
				<c:otherwise>
					<!-- Ordem dos botões SalvarESair e SalvarEDuplicar -->
					<c:choose>
						<c:when
							test="#{pManagedBean.isInverterOrdemBotoesSalvarESair_SalvarEDuplicar}">
							<p:commandButton ajax="false" id="btnSalvarEDuplicar"
								actionListener="#{pManagedBean.doSalvarEDuplicar}"
								value="#{pManagedBean.labelSalvarEDuplicar}"
								update="panelFormularioEdicao,panelFiltroPesquisa,panelListagem,exportador#{pManagedBean.updateExtraBtnSalvarEDuplicar}"
								rendered="#{pManagedBean.isExibirBtnSalvarEDuplicar}" />
							<p:commandButton ajax="false" id="btnSalvarESair"
								action="#{pManagedBean.doSalvarESair}"
								value="#{pManagedBean.labelSalvarSair}"
								rendered="#{pManagedBean.isExibirBtnSalvarESair}" />
						</c:when>
						<c:otherwise>
							<p:commandButton ajax="false" id="btnSalvarESair"
								action="#{pManagedBean.doSalvarESair}"
								value="#{pManagedBean.labelSalvarSair}"
								rendered="#{pManagedBean.isExibirBtnSalvarESair}" />

							<p:commandButton ajax="false" id="btnSalvarEDuplicar"
								actionListener="#{pManagedBean.doSalvarEDuplicar}"
								value="#{pManagedBean.labelSalvarEDuplicar}"
								update="panelFormularioEdicao,panelFiltroPesquisa,panelListagem,exportador#{pManagedBean.updateExtraBtnSalvarEDuplicar}"
								rendered="#{pManagedBean.isExibirBtnSalvarEDuplicar}" />
						</c:otherwise>
					</c:choose>
					<p:commandButton ajax="false" id="btnSalvar"
						action="#{pManagedBean.doSalvar}"
						value="#{pManagedBean.labelSalvar}" update="msgs,form"
						rendered="#{pManagedBean.isExibirBtnSalvar}" />

					<ui:insert name="demaisBotoesFormulario" />

					<p:commandButton ajax="false" id="btnCancelar"
						action="#{pManagedBean.doCancelar}"
						value="#{pManagedBean.labelCancelar}" immediate="true"
						rendered="#{pManagedBean.isExibirBtnCancelar}" />
				</c:otherwise>
			</c:choose>

		</c:if>
		<c:if test="#{pManagedBean.tipoOperacao == 'DETALHANDO'}">
			<p:commandButton ajax="false" id="btnVoltar"
				action="#{pManagedBean.doVoltar}"
				value="#{pManagedBean.labelVoltar}" immediate="true" />
		</c:if>
	</h:panelGrid>

</ui:composition>

</html>